package com.ashin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @Author: Ashin
 * @Date: 2021/5/10
 * @Description: com.ashin.controller
 * @Version: 1.0.0
 */
@RestController
public class HelloRedisController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RequestMapping("/cluster")
    public String publish() {
        System.out.println(stringRedisTemplate);
        Random random = new Random();
        random.ints().limit(1000).forEach((i) -> {
            stringRedisTemplate.opsForValue().set("zjh" + i, "ddddddd" + i);
        });
        System.out.println(stringRedisTemplate.opsForValue().get("zjh"));
        return "结束";
    }


}
